#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <unistd.h>

#include <stdio.h>

#include "testled.h"

int main(int argc,char *argv[])
{
	int fd = -1;
	int onoff = 0;
	int ledno = 0;

	if(argc < 4)
	{
		printf("The main arguments is too few\n");
		return 1;
	}

	sscanf(argv[2],"%d",&onoff);
	sscanf(argv[3],"%d",&ledno);
	if(ledno < 2 || ledno > 5)
	{
		printf("ledno is invalid\n");
		return 2;
	}

	fd = open(argv[1],O_RDONLY);
	if(fd < 0)
	{
		printf("open %s failed\n",argv[1]);
		return 2;
	}

	if(onoff)
	{
		ioctl(fd,LED_NO,ledno);
	}
	else
	{
		ioctl(fd,LED_OFF,ledno);
	}

	close(fd);
	fd = -1;

	return 0;
}
